package cn.com.doone.common.uc.web;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

public class BaseController {

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public Map<String, Object> getParams(HttpServletRequest request) {
		Map params = new HashMap();
		Set key = request.getParameterMap().keySet();
		for (Iterator it = key.iterator(); it.hasNext();) {
			String name = (String) it.next();
			Object[] value = (Object[]) request.getParameterMap().get(name);
			if (value.length == 1) {
				if ((value[0] != null) && (value[0].toString().length() > 0))
					params.put(name, value[0]);
			} else if (value.length > 1) {
				params.put(name, value);
			}

		}
		return params;
	}
}
